<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="product in products">
            {{ product.name }} : {{ product.price * 80 / 100 + '元' }}
        </li>
    </ul>
    <ul>
        <li v-for="product in products">
            {{ product.name }} : {{ product.price | discountFn(50) | formatFn() }}
        </li>
    </ul>
</div>

</body>
<script>
let app = new Vue({
    el: '#app',
    data: {
        products: [
            {
                id: 1,
                name: 'Apple iPhone 14 Pro',
                price: 7999,
            },
            {
                id: 2,
                name: 'Model 3',
                price: 279900,
            }
        ]
    },
    filters: {
        discountFn: function(val, d) {
            return val * d / 100

        },
        formatFn: function(val) {
            return val + '元'
        }
    }
})


</script>
</html>
